//
//  InputTempletTenTableViewCell.m
//  CedarFinancePH
//
//  Created by menchao on 2018/9/3.
//  Copyright © 2018年 cedarhd. All rights reserved.
//

#import "InputTempletTenTableViewCell.h"


@interface InputTempletTenTableViewCell ()

@property (nonatomic,strong) UILabel *titleLbl;
@property (nonatomic,strong) UILabel *subtitleLbl;
@property (nonatomic,strong) CedarButton *iconButton;

@end


@implementation InputTempletTenTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self!=nil){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLbl];
        [self.contentView addSubview:self.iconButton];
        [self.contentView addSubview:self.subtitleLbl];
        [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.contentView);
        }];
        [self.iconButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.titleLbl.mas_right).mas_offset(8);
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(30, 30));
        }];
        
        
        self.subtitleLbl.textAlignment = NSTextAlignmentRight;
        [self.subtitleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).mas_offset(-kMarginOffsetX);
            make.centerY.mas_equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)updateTitle:(NSString *)title subtitle:(NSString *)subtitle{
    self.titleLbl.text = title;
    if(subtitle){
        self.subtitleLbl.text = subtitle;
    }
    if(self.iconButton.hidden){
        self.iconButton.hidden = NO;
    }
}



- (void)updateTitle:(NSString *)title subtitle:(NSString *)subtitle hideIcon:(BOOL)isHide{
    self.titleLbl.text = title;
    if(subtitle){
        self.subtitleLbl.text = subtitle;
    }
    self.iconButton.hidden = isHide;
}


- (CedarButton *)iconButton{
    if (!_iconButton) {
        _iconButton = [CedarButton buttonWithImageName:@"Tips2"];
        @weakify(self)
        _iconButton.clickEvent = ^{
            @strongify(self)
            if(self.clickBlock){
                self.clickBlock();
            }
        };
    }
    return _iconButton;
}

MACRO_UILabelWithPFCGFont(titleLbl, @"",kGrayColor, 14)
MACRO_UILabelWithPFCGFont(subtitleLbl, @"",kBlackColor, 14)

@end
